#include "tools.h"
#include"utils.h"

Tools::Tools()
{
}


void Tools::Boneset(Building *building)
{
    for(int i = building->CurrentPeopleAccessor().count() - 1; i >= 0; i--)
    {
        building->CurrentPeopleAccessor().at(i)->stats->setHP(building->CurrentPeopleAccessor().at(i)->stats->getHP() + 500);
    }
}

void Tools::PlaceboMagic(Building *building)
{
    for(int i = building->CurrentPeopleAccessor().count() - 1; i >= 0; i--)
    {
        int random = rand() % 100;
        if(random <= 35)
            building->CurrentPeopleAccessor().at(i)->stats->setImmuneResponse(building->CurrentPeopleAccessor().at(i)->stats->getImmuneResponse() + 700);
    }
}

void Tools::CoughSyrup(Building *building)
{
    for(int i = building->CurrentPeopleAccessor().count() - 1; i >= 0; i--)
    {
        building->CurrentPeopleAccessor().at(i)->stats->setCleanliness(building->CurrentPeopleAccessor().at(i)->stats->getCleanliness() + 400);
    }
}

void Tools::Interferons(Building *building)
{
    for(int i = building->CurrentPeopleAccessor().count() - 1; i >= 0; i--)
    {
        building->CurrentPeopleAccessor().at(i)->stats->setImmuneResponse(building->CurrentPeopleAccessor().at(i)->stats->getImmuneResponse() + 300);
    }

}

 void Tools::Antivirals(Building *building)
{
    for(int i = building->CurrentPeopleAccessor().count() - 1; i >= 0; i--)
    {
        if(building->CurrentPeopleAccessor().at(i)->virus != 0)
            building->CurrentPeopleAccessor().at(i)->virus->HP -= rand() % 1000;
    }
}

 void Tools::Gammaglobulins(Building *building)
{
    for(int i = building->CurrentPeopleAccessor().count() - 1; i >= 0; i--)
    {
        building->CurrentPeopleAccessor().at(i)->stats->useGammaglobulins();
    }
}

 void Tools::Sterilization(Building *building)
{
    building->SterilitySetter(building->SterilityGetter() + 4);
}

 void Tools::CleanWater(QList<Building *> buildings)
 {
     for (int index = 0; index < buildings.length(); index++)
     {
         Sterilization(buildings.at(index));
     }
 }

 void Tools::Vaccene(Building *building)
{
    for(int i = building->CurrentPeopleAccessor().count() - 1; i >= 0; i--)
    {
        building->CurrentPeopleAccessor().at(i)->stats->setResistence(500);
    }
}

 void Tools::GeneTherapy(Building *building)
 {
     for(int i = building->CurrentPeopleAccessor().count() - 1; i >= 0; i--)
     {
        building->CurrentPeopleAccessor().at(i)->stats->setResistence(1000);
        building->CurrentPeopleAccessor().at(i)->stats->setImmuneResponse(building->CurrentPeopleAccessor().at(i)->stats->getImmuneResponse() + 200);
        building->CurrentPeopleAccessor().at(i)->stats->setImmuneStrength(building->CurrentPeopleAccessor().at(i)->stats->getImmuneStrength() + 200);
     }
 }
 
 void Tools::NanobotTherapy(Building *building)
 {
     for(int i = building->CurrentPeopleAccessor().count() - 1; i >= 0; i--)
     {
        delete building->CurrentPeopleAccessor().at(i)->virus; 
        building->CurrentPeopleAccessor().at(i)->virus = 0;
     }
 }



